function BBComplex(){
/*
bbComplex - JavaScript     uCoz
   23/VII 2009 .
Copyright  VACion, 2009
 : http://vacionlib.org.ru/forum/18-49-1
*/

//
	//  BB-  [code]
	//:      BB-!          [code]     false!
		disableBBInCode=true;
	//  (!)   .        ,                    .
	//:         "/"  .  "/bbicons",  "/bbicons/"   "http://mysite.com/bbicons",  "http://mysite.com/bbicons/".
		DefMsgIconUrl="http://logical.nxt.ru/justforgame/bbicons/";

	//  BB-
	//!!!
	//:  BB-,   ,  ,   ,   ,     .
	// .  ,    BB-,   .
	// ,   :    BB-,   .
		this.bbcarray=function(){return([bbcode_cut,bbcode_cut_ng,bbcode_table,bbcode_tr,bbcode_td,bbcode_dashedu,bbcode_doubleu,bbcode_wavy_green_u,bbcode_wavy_red_u,bbcode_highlight,bbcode_indent,bbcode_notice,bbcode_warn,bbcode_teletype,bbcode_ancor,bbcode_addtitle,bbcode_offtop,bbcode_move,bbcode_flv,bbcode_blink]);}
	
	/*   BB-:
	1.   :
		bbcode_MYBBCODE={"Type":,"Value":" BB-","CodeStart":'HTML-  BB-',"CodeEnd":'HTML-  BB-'};
		 -  1,     ,   ,  2 -  .
		HTML-  BB-:
			   .
			: {$_[:HTML-    ]}
			   $BBID$,        BB-.
	2.  bbcode_MYBBCODE  this.bbcarray,      .
	3.      BB-,  .
	*/

	//
		defCut="cut";
		defCutNG="cut noguest";
		//   
		dCHG=false;
		//HTML- 
		dCSC='<div id="$BBID$SpTitle0" class="spMsgTitle0"><a class="spMsgTitle0Link" href="javascript://" onclick="bbcobj.tsp(\'$BBID$\',1);return false;" title="  ">[ {$0: } ]</a></div><div id="$BBID$SpTitle1" class="spMsgTitle1" style="display: none;"><a class="spMsgTitle1Link" href="javascript://" onclick="bbcobj.tsp(\'$BBID$\',0);return false;" title=" ">[ {$0:} ]</a></div><div id="$BBID$SpMessage" class="spMsgText" style="display: none;">';
		//HTML-    
		dCNG='<div class="spMsgTitle2"><a class="spMsgTitle2Link" href="javascript://" onclick="openLayerB(\'LF\',0,\'/index/40\',\'Login\',250,130,1);return false;">[     ]</a></div><div style="display:none;">';
		dCEC='</div>';

		//  BB-      .
		bbcode_cut={"Type":1,"Value":defCut,"CodeStart":function(){return(dCHG&&!ULI?dCNG:dCSC);},"CodeEnd":dCEC,"Comma":1};
		bbcode_cut_ng=dCHG?{}:{"Type":1,"Value":defCutNG,"CodeStart":function(){return(ULI?dCSC:dCNG);},"CodeEnd":dCEC,"Comma":1};

	//
		bbcode_table={"Type":1,"Value":"table","CodeStart":'<table style="width:{$0:100%};border:1px solid #000000;border-collapse:collapse;" cellpadding="0" cellspacing="0">',"CodeEnd":'</table>'};
		bbcode_tr={"Type":1,"Value":"tr","CodeStart":'<tr>',"CodeEnd":'</tr>'};
		bbcode_td={"Type":1,"Value":"td","CodeStart":'<td style="width:{$0:auto};height:{$1:auto};border:1px solid #000000;" valign="{$2:middle}" colspan="{$3:1}">',"CodeEnd":'</tr>'};

	//BB- 
		//
		defDashed="dashed";
		bbcode_dashedu={"Type":1,"Value":defDashed,"CodeStart":'<font style="line-height: 1.5;border-bottom: 1px dashed;">',"CodeEnd":'</font>'};
		//
		defDouble="double";
		bbcode_doubleu={"Type":1,"Value":defDouble,"CodeStart":'<font style="line-height: 1.5;border-bottom: 3px double;">',"CodeEnd":'</font>'};
		//(  )
		defWawygreen="wavygreen";
		bbcode_wavy_green_u={"Type":1,"Value":defWawygreen,"CodeStart":'<font style="line-height: 1.5;background: url(\''+DefMsgIconUrl+'wave_green.gif\') repeat-x 100% 100%;white-space: nowrap;padding-bottom: 2px;">',"CodeEnd":'</font>'};
		defWawyred="wavyred";
		bbcode_wavy_red_u={"Type":1,"Value":defWawyred,"CodeStart":'<font style="line-height: 1.5;background: url(\''+DefMsgIconUrl+'wave_red.gif\') repeat-x 100% 100%;white-space: nowrap;padding-bottom: 2px;">',"CodeEnd":'</font>'};

	//BB- 
		//
		defHighlight="bgcolor";
		bbcode_highlight={"Type":1,"Value":defHighlight,"CodeStart":'<div style="background-color:{$0:transparent};display:inline;">',"CodeEnd":'</div>'};
		//
		defIndent="indent";
		bbcode_indent={"Type":1,"Value":defIndent,"CodeStart":'<div style="padding-left:20px;display:inline;">',"CodeEnd":'</div>'};
		//
		defNotice="notice";
		bbcode_notice={"Type":1,"Value":defNotice,"CodeStart":'<div class="bbNoticeName" style="padding-left:5px;font-weight:bold;"></div><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td class="bbNoticeMessage" style="border:1px inset;max-height:200px;overflow:auto;"><img src="'+DefMsgIconUrl+'misc/notice.gif" align="left" border="0" />',"CodeEnd":'</td></tr></table>'};
		//
		defWarn="warn";
		bbcode_warn={"Type":1,"Value":defWarn,"CodeStart":'<div class="bbWarningName" style="padding-left:5px;font-weight:bold;"></div><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td class="bbWarningMessage" style="border:1px inset;max-height:200px;overflow:auto;"><img src="'+DefMsgIconUrl+'misc/warn.gif" align="left" border="0" />',"CodeEnd":'</td></tr></table>'};
		//
		defTT="tt";
		bbcode_teletype={"Type":1,"Value":defTT,"CodeStart":'<tt>',"CodeEnd":'</tt>'};
		//
		defAncor="ancor";
		bbcode_ancor={"Type":1,"Value":defAncor,"CodeStart":'<a name="bbancor_{$0}">',"CodeEnd":'</a>'};
		//  
		defSText='addtitle';
		bbcode_addtitle={"Type":1,"Value":defSText,"CodeStart":'<div style="display:inline;" title="{$0: }">',"CodeEnd":'</div>',"Comma":1};
		//
		defOff='off';
		bbcode_offtop={"Type":1,"Value":defOff,"CodeStart":'<div class="bbOffName"></div><div class="bbOffMessage" style="color:gray;border:1px inset;max-height:200px;overflow:auto;height:expression(this.scrollHeight>230?\'200px\':\'auto\');">',"CodeEnd":'</div>'}

	// BB-
		// 
		defMove='move';
		bbcode_move={"Type":1,"Value":defMove,"CodeStart":'<marquee behavior="{$1:scroll}" direction="{$0:left}">',"CodeEnd":'</marquee>'};

		//FlV-
		defPlayer="player";
		// ()
		defFLVbackpict=false; // - "http://mysite.ru/flvplayer.png"
		//
		defFLVtitlepict=false; // - "http://mysite.ru/flvplogo.png"
		// 
		defFLVbackcolor="447136";
		defFLVfrontcolor="1e9a17";
		bbcode_flv={"Type":1,"Value":defPlayer,"CodeStart":'<embed src="http://vacionlib.org.ru/player/player.swf" allowscriptaccess="always" allowfullscreen="true" flashvars="height=375&width=500&file=$INNERHTML$'+(defFLVbackpict!=false?('&image='+defFLVbackpict):'')+'&backcolor=0x'+(defFLVbackcolor!=false?defFLVbackcolor:'ff8300')+'&frontcolor='+(defFLVfrontcolor?defFLVfrontcolor:'a5de1e')+'"'+(defFLVtitlepict?('&logo='+defFLVtitlepict+' '):' ')+'height="375" width="500">'};

		// 
		//    (1/1000 )
		defBlinkTimeout=900;
		defBlink="blink";
		bbcode_blink={"Type":1,"Value":defBlink,"CodeStart":'<span name="UBlinkA">',"CodeEnd":'</span>'}; //  

	 //  
	/*         bb-.      ,   .
	  : smfdarkgreen, smfgrey, smfblue, classic, classicflat, classicgreen, classicgreenfl, darkstone, modern, vista
	     .*/
		//   bb-
	_bb_PanelButtonTheme="modern";
		//  bb-(false  )
	_bb_PanelImgTheme=false;
		//     .        ,    .
		 //       
	DefMsgIconBackgroundImageDefault="/bbc_bg.gif";
		 //           
	DefMsgIconBackgroundImageOver="/bbc_hoverbg.gif";
		 //          
	DefMsgIconBackgroundImageMark="/bbc_markbg.gif";
		 //          
	DefMsgIconBackgroundImageMarked="/bbc_markedbg.gif";
		 //     
	DefMsgPanelBGImage="/pbu.gif"; // false,   
		 //      
	DefMsgPanelLineImage="/pbg.gif"; // false,   
		 //       
	DefMsgIconBackground="url('"+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageDefault+"')";
		// : true -        , false -  .
	HighLightButtons=true;
		 //    :    false,     .
	HighLightUnclosedTagButtons=true;
		 //    
	text_enter_url="URL- ";
		 //    
	text_enter_url_name=" ";
		 //    
	text_enter_image="URL- ";
		 //   e-mail 
	text_enter_email="E-mail ";
		 //    
	list_prompt=" ";
	  //  bb-
	   /*  bb-.    ,     .     HTML-,      ("  '). :      bb_special()  bb_preview().
	   :

	bb_special(),
	'<a href="http://myurl.com/"> </a>',
	bb_preview()

	     ,  ,   .*/
	panel_array=function(){return([
	bb_capsulastart(),
	bb_bold(),
	bb_italicize(),
	bb_underline(),
	bb_defmove(),
	new_bb_Block(bb_customblock1()),
	bb_divider(),
	bb_left(),
	bb_center(),
	bb_right(),
	bb_pre(),
	bb_indent(),
	bb_divider(),
	bb_sub(),
	bb_sup(),
	bb_divider(),
	bb_table(),
	bb_divider(),
	bb_list(),
	bb_hide(),
	bb_divider(),
	bb_smls(),
	bb_keybrd(),
	bb_translit(),
	bb_doubledivider(),
	bb_closeall(),
	bb_breakspace(),
	bb_url(),
	bb_email(),
	bb_img(),
	bb_divider(),
	bb_TT(),
	bb_code(),
	bb_offtop(),
	bb_quote(),
	bb_defcut(),
	bb_divider(),
	bb_hr(),
	bb_divider(),
	bb_video(),
	bb_flv(),
	bb_snd(),
	bb_divider(),
	bb_graffiti(),
	bb_capsulaend(),
	bb_fsize(),
	bb_space(),
	bb_font(),
	bb_space(),
	bb_fcolor(),
	bb_space(),
	bb_highlight(),
	bb_space(),
	bb_special()
	]);}

	bb_customblock1=function(){return([
	bb_strike(),
	bb_over(),
	bb_blink(),
	bb_doubleunderline(),
	bb_dashedunderline(),
	bb_wavygreen(),
	bb_wavyred(),
	bb_stext()
	]);}

	   //  BB-
		//     _bb_Button.  _bb_Button    .
		// - _bb_Button([["",],["",],<...>,["",]])
		// - "Type", "Value", "Where", "Title", "GIFImage", "Special"
		//"Type" -  .    :
		 //0-"special" -    "Special"(  _bb_set)      .
		 //  0   "Special"    ,     13
		 //1-"simple" -   BB-.
		 //2-"once" - BB-,   .
		 //3-"url", 4-"email", 5-"img", 6-"cut", 7-"list", 8-"video", 9-"audio", 10-"sml", 11-"keybrd", 12-"translit"
		 //13-"none" -   "Type" >= 13    ,    .
		//"Value" -   BB-
		//"Where" -      ID. -, "message".
		//"Title" -  
		//"GIFImage" -    GIF. ,      ,  , ,       DefMsgIconUrl,   .gif
		//"Special" -      javascript.   onClick="..."     < 13
	bb_bold=function(){return(_bb_Button([["Type",1],["Value","b"],["Where","message"],["Title",""],["GIFImage","bold"]]));}
	bb_blink=function(){return(_bb_Button([["Type",1],["Value",defBlink],["Where","message"],["Title",""],["GIFImage","blink"]]));}
	bb_doubleunderline=function(){return(_bb_Button([["Type",1],["Value",defDouble],["Where","message"],["Title"," "],["GIFImage","double"]]));}
	bb_stext=function(){return(_bb_Button([["Type",0],["Value",defSText],["Title"," "],["GIFImage","stext"],["Special","bbcobj.tag_stext('message',event);"]]));}
	bb_dashedunderline=function(){return(_bb_Button([["Type",1],["Value",defDashed],["Where","message"],["Title"," "],["GIFImage","dashed"]]));}
	bb_wavygreen=function(){return(_bb_Button([["Type",1],["Value",defWawygreen],["Where","message"],["Title","   "],["GIFImage","wavygreen"]]));}
	bb_wavyred=function(){return(_bb_Button([["Type",1],["Value",defWawyred],["Where","message"],["Title","   "],["GIFImage","wavyred"]]));}
	bb_italicize=function(){return(_bb_Button([["Type",1],["Value","i"],["Where","message"],["Title",""],["GIFImage","italicize"]]));}
	bb_underline=function(){return(_bb_Button([["Type",1],["Value","u"],["Where","message"],["Title",""],["GIFImage","underline"]]));}
	bb_defmove=function(){return(_bb_Button([["Type",1],["Value", defMove],["Where","message"],["Title"," "],["GIFImage","move"]]));}
	bb_strike=function(){return(_bb_Button([["Type",1],["Value","s"],["Where","message"],["Title",""],["GIFImage","strike"]]));}
	bb_over=function(){return(_bb_Button([["Type",1],["Value","o"],["Where","message"],["Title",""],["GIFImage","over"]]));}
	bb_url=function(){return(_bb_Button([["Type",0],["Value","url"],["Title",""],["Special","bbcobj.tag_url('message',event);"],["GIFImage","url"]]));}
	bb_email=function(){return(_bb_Button([["Type",0],["Value","email"],["Title","E-mail"],["Special","bbcobj.tag_email('message',event);"],["GIFImage","email"]]));}
	bb_img=function(){return(_bb_Button([["Type",0],["Value","img"],["Title",""],["Special","bbcobj.tag_image('message',event);"],["GIFImage","img"]]));}
	bb_defcut=function(){return(_bb_Button([["Type",0],["Title",""],["Value", defCut],["Special","bbcobj.tag_cut('message',event);"],["GIFImage","cut"]]));}
	bb_quote=function(){return(_bb_Button([["Type",1],["Value","quote"],["Where","message"],["Title",""],["GIFImage","quote"]]));}
	bb_offtop=function(){return(_bb_Button([["Type",1],["Value", defOff],["Where","message"],["Title",""],["GIFImage","offtop"]]));}
	bb_hide=function(){return(_bb_Button([["Type",1],["Value","hide"],["Where","message"],["Title","  "],["GIFImage","hide"]]));}
	bb_TT=function(){return(_bb_Button([["Type",1],["Value",defTT],["Where","message"],["Title"," teletype-"],["GIFImage","tele"]]));}
	bb_code=function(){return(_bb_Button([["Type",1],["Value","code"],["Where","message"],["Title",""],["GIFImage","code"]]));}
	bb_list=function(){return(_bb_Button([["Type",0],["Title",""],["Special","bbcobj.tag_list('message',event);"],["GIFImage","list"]]));}
	bb_left=function(){return(_bb_Button([["Type",1],["Value","l"],["Where","message"],["Title","  "],["GIFImage","left"]]));}
	bb_center=function(){return(_bb_Button([["Type",1],["Value","c"],["Where","message"],["Title"," "],["GIFImage","center"]]));}
	bb_right=function(){return(_bb_Button([["Type",1],["Value","r"],["Where","message"],["Title","  "],["GIFImage","right"]]));}
	bb_pre=function(){return(_bb_Button([["Type",1],["Value","j"],["Where","message"],["Title"," "],["GIFImage","pre"]]));}
	bb_indent=function(){return(_bb_Button([["Type",1],["Value","indent"],["Where","message"],["Title",""],["GIFImage","indent"]]));}
	bb_sub=function(){return(_bb_Button([["Type",1],["Value","sub"],["Where","message"],["Title"," "],["GIFImage","sub"]]));}
	bb_sup=function(){return(_bb_Button([["Type",1],["Value","sup"],["Where","message"],["Title"," "],["GIFImage","sup"]]));}
	bb_video=function(){return(_bb_Button([["Type",0],["Value","video"],["Title",""],["Special","bbcobj.tag_video('message',event);"],["GIFImage","video"]]));}
	bb_flv=function(){return(_bb_Button([["Type",0],["Value",defPlayer],["Title","FLV-Player"],["Special","bbcobj.tag_flv('message',event);"],["GIFImage","player"]]));}
	bb_snd=function(){return(_bb_Button([["Type",0],["Value","audio"],["Title",""],["Special","bbcobj.tag_audio('message',event);"],["GIFImage","snd"]]));}
	bb_hr=function(){return(_bb_Button([["Type",2],["Value","hr"],["Where","message"],["Title",""],["GIFImage","hr"]]));}
	bb_smls=function(){return(_bb_Button([["Type",0],["Title"," "],["Special","openLayerB('Sml',0,'/index/35-23-0','  ',250,350);return false;"],["GIFImage","smls"]]));}
	bb_keybrd=function(){return(_bb_Button([["Type",0],["Title"," "],["Special","window.open('/forum/0-0-0-31','virtKB','width=300,height=120,top=0,left=0');"],["GIFImage","keyboard"]]));}
	bb_translit=function(){return(_bb_Button([["Type",0],["Title"," "],["Special","openLayerB('TranslitBody',0,'/translit/translit.xml',' ',460,320,1,0,0);"],["GIFImage","translit"]]));}
	bb_graffiti=function(){return(_bb_Button([["Type",0],["Special","window.open('/media/?t=draw;h=1','grafwind','width=800,height=600,top=0,left=0');"],["Title",""],["GIFImage","graffiti"]]));}
	bb_closeall=function(){return(_bb_Button([["Type",0],["Special","bbcobj.closeall('message','');"],["Title","   "],["GIFImage","closeall"]]));}
	bb_table=function(){return(_bb_Button([["Type",0],["Special","bbcobj.tag_table('message',event);"],["Title"," "],["GIFImage","table"]]));}

	   //  
	bb_capsulastart=function(){return('<div style="padding-right:1px;'+(DefMsgPanelLineImage?'background:url(\''+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgPanelLineImage+'\');':'')+'">');}
	bb_capsulaend=function(){return('</div>');}

	   // (HTML-)
	bb_divider=function(){return('<img align="middle" border=0 src="' + DefMsgIconUrl + _bb_PanelButtonTheme + '/divider.gif" alt="|" style="margin: 0 2px 0 3px;" />');}
	bb_doubledivider=function(){return('<img align="middle" border=0 src="' + DefMsgIconUrl + _bb_PanelButtonTheme + '/divider.gif" alt="|" style="margin: 0 0px 0 3px;" /><img align="middle" border=0 src="' + DefMsgIconUrl + _bb_PanelButtonTheme + '/divider.gif" alt="|" style="margin: 0 2px 0 0px;" />');}

	   //   
		//()
	x_imageBlockIcon_op="block/op1.gif";
		//()
	x_imageBlockIcon_cl="block/op2.gif";
		//
	bb_inblock_st=function(){return('<a href="javascript://" onclick="bbcobj.toggle_show_inline(\'newBBlockSpan'+_bb_blockcount+'\');bbcobj._bb_userblock_togglepict(document.getElementById(\'newBBlockImage'+_bb_blockcount+'\'));return false;"><img alt=">" id="newBBlockImage'+_bb_blockcount+'" title="/ " align="middle" border="0" src="' + DefMsgIconUrl+x_imageBlockIcon_cl + '" style="margin-left: 3px; margin-right: 2px;"/></a><span id="newBBlockSpan'+_bb_blockcount+'" style="display: none">');}
		//
	bb_inblock_post_st=function(){return('</span>');}

	   //  
	bb_breakspace=function(){return(bb_capsulaend()+bb_capsulastart());}

	   // 
	bb_breakspace_normal=function(){return('<br/>');}

	   //
	bb_space=function(){return(' ');}

	   // 
	bb_fsize=function(){return('<select name="fsize" class="codeButtons" onchange="bbcobj.alterfont(this.options[this.selectedIndex].value,\'size\',\'message\',\'\');this.selectedIndex=0;"><option value="0"></option><option value="8">8 pt</option><option value="9">9 pt</option><option value="10">10 pt</option><option value="11">11 pt</option><option value="12">12 pt</option><option value="13">13 pt</option><option value="14">14 pt</option><option value="15">15 pt</option><option value="16">16 pt</option><option value="17">17 pt</option><option value="18">18 pt</option></select>');}

	   // 
	bb_fcolor=function(){return('<select name="fcolor" class="codeButtons" onchange="if(this.options[this.selectedIndex].value==\'choosebox\'){document.getElementById(\'bbColorSelect\').style.display=\'inline\';this.selectedIndex=0;return false;}bbcobj.alterfont(this.options[this.selectedIndex].value, \'color\',\'message\',\'\');this.selectedIndex=0;document.getElementById(\'bbColorSelect\').style.display=\'none\';"><option value="0"></option><option value="blue" style="color:blue"></option><option value="red" style="color:red"></option><option value="purple" style="color:purple"></option><option value="orange" style="color:orange"></option><option value="yellow" style="color:yellow">Ƹ</option><option value="gray" style="color:gray"></option><option value="green" style="color:green"></option><option value="#EF84B5" style="color:#EF84B5;"></option><option value="choosebox">...</option></select><input type="image" onclick="bbcobj.openPicker(this,\'colorselect\');return false;" id="bbColorSelect" style="display:none;border:1px outset #AAAAAA;" src="'+DefMsgIconUrl+'color.gif" width="14" height="14" value="" title=" ">');}

	   // 
	bb_highlight=function(){return('<select name="htbgcolor" class="codeButtons" onchange="if(this.options[this.selectedIndex].value==\'choosebox\'){document.getElementById(\'bbHTBGSelect\').style.display=\'inline\';this.selectedIndex=0;return false;}bbcobj.alterfont(this.options[this.selectedIndex].value, \''+defHighlight+'\',\'message\',\'\');this.selectedIndex=0;document.getElementById(\'bbHTBGSelect\').style.display=\'none\';"><option value="0"></option><option value="blue" style="color:blue"></option><option value="red" style="color:red"></option><option value="purple" style="color:purple"></option><option value="orange" style="color:orange"></option><option value="yellow" style="color:yellow">Ƹ</option><option value="gray" style="color:gray"></option><option value="green" style="color:green"></option><option value="#EF84B5" style="color:#EF84B5;"></option><option value="choosebox">...</option></select><input type="image" onclick="bbcobj.openPicker(this,\'HTBGselect\');return false;" id="bbHTBGSelect" style="display:none;border:1px outset #AAAAAA;" src="'+DefMsgIconUrl+'bgcolor.gif" width="14" height="14" value="" title=" ">');}

	   //
	bb_font=function(){return('<select name="ffont" class="codeButtons" onchange="bbcobj.alterfont(this.options[this.selectedIndex].value,\'font\',\'message\',\'\');this.selectedIndex=0;"><option value="0"></option><option value="Arial">Arial</option><option value="Times">Times</option><option value="Courier">Courier</option><option value="Impact">Impact</option><option value="Geneva">Geneva</option><option value="Optima">Optima</option></select>');}

	   // 
	bb_special=function(){return('<select name="newsymbols" class="codeButtons" onchange="bbcobj.symbolinssert(this.options[this.selectedIndex].value,\'message\');this.selectedIndex=0;"><option value="0"> </option><option value="&#x301;">*&#x301;*</option><option value="^">^</option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value=""></option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="v">v</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value=""></option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value=""></option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="?">?</option><option value="^????????v?????????????????????&#x301;"> !</option></select>');}

	//,  
	//--------------------------  --------------------------//

	pAR=this.bbcarray();
	gbbcnt=0;
	ULI=0;
	this.bbplugins={"StartSlot":[]};
	_bb_type=0;
	_bb_typearray=new Array("special","simple","once","none")
	_bb_value=null;
	_bb_where="message";
	_bb_title="Dummy button";
	_bb_GIFImage="Dummy_image";
	_bb_special=null;
	_bb_simplecodes_array=new Array();
	_bb_hihglight_array=new Array();
	_bb_blockcount=0;
	var BBScpCounter;
	if(!BBScpCounter){BBScpCounter=0;}
	BBSelColor="000000";
	pickedLayers={};
	layerWidth=218;
	layerHeight=144;
	bbSBMORVAL="";
	EMLrXp=new RegExp("[0-9a-z-_\.]+@[0-9a-z_^.]+.[a-z]{2,3}");
	HIDrXp=/^\d+$/;
	eCRegExp=/^\d{5,9}$/;

	String.prototype.GetFStartTEnd=function(fs_i,fs_j,bs_l,al)
	{
		var s=this,bs_l,fs_a,fs_b,fs_c;fs_i=fs_i.toString();fs_j=fs_j.toString();
		t=function(s,i,j){
			var k;if(al){fs_b=s.indexOf(j);if(fs_a==-1){return false;}fs_a=s.slice(0,fs_b).lastIndexOf(i);
			}else{fs_a=s.indexOf(i);if(fs_a==-1){return false;}fs_b=s.indexOf(j,fs_a);if(fs_b==-1){return false;}}}
		if(bs_l){t(s.toLowerCase(),fs_i.toLowerCase(),fs_j.toLowerCase());}else{t(s,fs_i,fs_j);}
		fs_c=fs_a+fs_i.length;
		return s.substr(fs_c,fs_b-fs_c);
	}

	gEBC=function(n,p,m,callback){for(var e=p.getElementsByTagName(m?m:"*"),c,a=[],i=0;i<e.length;i++){c=e[i];if(!c.className){continue;}for(var b=0,t,p=c.className.split(' ');b<=p.length;b++){t=p[b];p=n.constructor==Array;for(j=0;j<(p?n.length:1);j++){if(t==(p?n[j]:n)){if(callback.constructor==Array){callback[j](c);}else{callback(c)};a[a.length]=c;break;}}}}return a;};

	this.tsp=function(sid,mode){
		if(mode==1){
			if(SM=document.getElementById(sid+"SpMessage")){SM.style.display="";}
			if(ST0=document.getElementById(sid+"SpTitle0")){ST0.style.display="none";}
			if(ST1=document.getElementById(sid+"SpTitle1")){ST1.style.display="";}
		}else{
			if(SM=document.getElementById(sid+"SpMessage")){SM.style.display="none";}
			if(ST0=document.getElementById(sid+"SpTitle0")){ST0.style.display="";}
			if(ST1=document.getElementById(sid+"SpTitle1")){ST1.style.display="none";}
		}
	}

	this.BBCode_Register=function(o){bbcarray.push(o);}

	HasBBTag=function(SM,Tag){
		if(Tag.Type==1&&(SM.lastIndexOf('['+Tag.Value+']')>-1||(Tag.CodeStart.indexOf("{$0")>-1&&SM.lastIndexOf('['+Tag.Value+'=')>-1)||SM.lastIndexOf('[/'+Tag.Value+']')>-1)) return true;
		if(Tag.Type==2&&(SM.lastIndexOf('['+Tag.Value+']')>-1||(Tag.CodeStart.indexOf("{$0")>-1&&SM.lastIndexOf('['+Tag.Value+'=')>-1))) return true;
		return false;
	}

	repSC=function(s){var h={'"':"&quot;",'&':"&amp;","'":"&#039;",'<':"&lt;",'>':"&gt;"},S,eT;for(S in h){eT=h[S];s=s.split(S).join(eT);}return s;}

	pPM=function(s,prID,arrSP)
	{
		var arrSP;
		sPsrc='{$'+prID;
		while(s.indexOf(sPsrc)>-1){
			Exp=s.GetFStartTEnd(sPsrc,'}').split(':',2);bExpL=Exp.length;
			if(bExpL==2){ExpVal=sPsrc+':'+Exp[1]+'}';}else{ExpVal=sPsrc+'}';}
			while(s.indexOf(ExpVal)>-1){s=s.replace(ExpVal,arrSP?arrSP[prID]:(bExpL==2?Exp[1]:''));}
		}return(s);
	}

	parsePms=function(s,sP,comma){
		var sP;sP=sP?sP:'';var nSP,aSP,sPS,Exp,ExpV,i=0;gbbcnt++;if(s.indexOf('{$0')==-1){return(s);}
		if(sP){nSP=repSC(sP),aSP=comma?nSP.split(','):[nSP];for(i=0;i<aSP.length;i++){s=pPM(s,i,aSP);}}else{while(s.indexOf('{$'+i)>-1){s=pPM(s,i);i++;}}while(s.indexOf("$BBID$")>-1){s=s.replace("$BBID$","cBB_"+gbbcnt);}
		return(s);
	}

	getIsIH=function(s){return(s.indexOf('$INNERHTML$')>-1);}

	parseIH=function(s,bb,str,iO){
		var IH=false,iO,isIH;IH=str.GetFStartTEnd('['+bb+(iO?"="+iO:"")+']','[/'+bb+']');
		if(isIH=getIsIH(s)){
			if(IH){nIH=repSC(IH);while(getIsIH(s)){s=s.replace('$INNERHTML$',nIH);}
			}else{while(getIsIH(s)){s=s.replace('$INNERHTML$',"");}}}
		return([s,IH,isIH]);
	}

	GenericBB=function(msgStr,bbCode)
	{
		var bbVal=bbCode.Value,bbFlags=bbCode.Flags,bbTyp=bbCode.Type,bbCS=bbCode.CodeStart,bbCE=bbCode.CodeEnd,ParS,A,mSiH,isIH;
		isExt=(msgStr.indexOf('['+bbVal+'=')>-1);
		if(bbTyp==1||bbTyp==2){
			if(msgStr.indexOf("["+bbVal+"]")>-1||isExt)
			{
				if(isExt){ParS=msgStr.GetFStartTEnd("["+bbVal+"=","]",true);if(ParS){bbCS=parsePms(bbCS,ParS,bbCode.Comma?false:true);}}
				if(!ParS){bbCS=parsePms(bbCS,null,bbCode.Comma?false:true);}
				if(bbTyp==1){
					A=parseIH(bbCS,bbVal,msgStr,ParS);
					bbCS=A[0];mSiH=A[1];isIH=A[2];
				}if(isIH&&bbTyp==1){
					msgStr=msgStr.replace("["+bbVal+(isExt?"="+ParS:"")+"]"+(msgStr.indexOf("[/"+bbVal+"]")>-1?mSiH+"[/"+bbVal+"]":""),bbCS);
				}else{
					msgStr=msgStr.replace("["+bbVal+(isExt?"="+ParS:"")+"]",bbCS);}}
			if(bbTyp==1&&msgStr.indexOf("[/"+bbVal+"]")>-1){msgStr=msgStr.replace("[/"+bbVal+"]",bbCE);}}
		return(msgStr);
	}

	PSM=function(nSM,cCM,sSM,nMB)
	{
		var sSM,cSM=nSM;
		for(var i=0;i<pAR.length;i++){
			cAR=pAR[i];
			if(typeof(cAR.CodeStart)=="function"){cAR.CodeStart=cAR.CodeStart();}
			if(typeof(cAR.CodeEnd)=="function"){cAR.CodeEnd=cAR.CodeEnd();}
			if(cAR.Type==1||cAR.Type==2){while(HasBBTag(nSM,cAR)){nSM=GenericBB(nSM,cAR);}}
		}if(sSM&&cSM!=nSM){sSM=sSM.replace(cSM,nSM);}
		return(sSM?sSM:nSM);
	}

	getBlinks=function(){
		var elem=document.getElementsByTagName('*'),arr=new Array();
		for(var gbl=0;gbl<elem.length;gbl++){var att=elem[gbl].getAttribute("name");if(att=="UBlinkA"){arr.push(elem[gbl]);}}
		return arr;
	}

	startBlink=function(blnode){return function(){if(blnode.style.visibility!="hidden"){blnode.style.visibility="hidden";}else{blnode.style.visibility="";}setTimeout(startBlink(blnode),defBlinkTimeout);}}

	bbParse=function(sSM){
		RE1=/class=[\'\"]?bbCodeBlock[\'\"]?/i;
		if(disableBBInCode&&(RE1R=RE1.exec(sSM))){
			RE2S=sSM.GetFStartTEnd("<div",RE1R,true,true);
			RE2E=sSM.GetFStartTEnd(RE1R,">",true);
			RE2=new RegExp("<div"+RE2S+RE1R+RE2E+">","i");
			RE3S=/class=[\'\"]?bbCodeName[\'\"]?/i;
			RE3E=new RegExp("<\/div><\/div>","i");
			aSM=sSM.split(RE2);
			for(i=0;i<aSM.length;i++){
				cCM=false;
				cSM=aSM[i];
				if(RE3S.test(cSM)==true){
					RE4=RE3E.exec(cSM)[0];
					cCM=cSM.substr(0,cSM.indexOf(RE4));
					cCM=cCM.substr(0,Math.round(cCM.length/2))+"<?bbc>"+cCM.slice(Math.round(cCM.length/2));
					cSM=cSM.slice(cSM.indexOf(RE4)+RE4.length);}
				sSM=PSM(cSM,cCM,sSM,i);}}else{sSM=PSM(sSM);}
		return(sSM);
	}

	this.bbComplete=function(ID){
		document.getElementById("msg"+ID).innerHTML=bbParse(document.getElementById("msg"+ID).innerHTML);
		var blels=getBlinks();for(var blel=0;blel<blels.length;blel++){startBlink(blels[blel])();}
		throw("BBComplex Warning: deprecated feature.\nPlease use StartBBComplex() instead of bbComplete().\n");
	}

	this.setULI=function(){ULI=1;}

	tF=function(o){oIH=o.innerHTML;o.innerHTML=bbParse(oIH);}

	tdparse=[["posttdMessage"],[tF]];
	divparse=[["cMessage"],[tF]];

	this.StartBBComplex=function(){
		siteBBPanel=document.addform;
		if(siteBBPanel&&siteBBPanel.innerHTML.indexOf("{?BBPANEL?}")>-1){
			siteBBPanel.innerHTML=siteBBPanel.innerHTML.replace("{?BBPANEL?}",BBCPanel());}

		pAR=this.bbcarray();
		PSS=this.bbplugins.StartSlot;
		for(i=0;i<PSS.length;i++){PSS[i]();}
		gEBC(tdparse[0],document,"td",tdparse[1]);
		gEBC(divparse[0],document,"div",divparse[1]);
		var blels=getBlinks();
		for(blel=0;blel<blels.length;blel++){startBlink(blels[blel])();}
		return true;
	}

	this.toggle_show=function(id){document.getElementById(id).style.display=document.getElementById(id).style.display=='none'?'block':'none';}
	this.show=function(id){document.getElementById(id).style.display='block';return true;}
	this.show_inline=function(id){document.getElementById(id).style.display='inline';return true;}
	this.hide=function(id){document.getElementById(id).style.display='none';return true;}
	this.toggle_show_inline=function(id){document.getElementById(id).style.display=document.getElementById(id).style.display=='none'?'inline':'none';return true;}
	this.toggle_show_iblock=function(id){document.getElementById(id).style.display=document.getElementById(id).style.display=='none'?'inline-block':'none';return true;}

	function openPicker(Obj,pickerID){if(!pickedLayers[pickerID]){removeOtherPickerLayers(pickerID);createPickerLayer(pickerID,findPosX(Obj)+Obj.offsetWidth-110,findPosY(Obj)+18);}else{removeAllPickerLayers();}Obj.style.display="none";}

	this.openPicker=openPicker;

	function createPickerLayer(id,left,top){
		pickedLayers[id]=true;
		var width=layerWidth,height=layerHeight,zindex=1000,bgcolor="#d4d0c8",txtcolor="#000000",msg=getPickerContent(id);
		if(document.layers){
			if(document.layers[id]){return;}
			var layer=document.layers[id]=new Layer(width);
			layer.className="picker_layer";layer.name=id;layer.left=left;layer.top=top;layer.clip.height=height;layer.visibility='show';
			layer.zIndex=zindex;layer.bgColor=bgcolor;layer.innerHTML=msg;}
		else if(document.all){
			if(document.all[id]){return}
			var layer='\n<DIV class="picker_layer" id='+id+' style="font-family:Arial,Helvetica,sans-serif;font-size:12px;text-decoration:none;background-color:#d4d0c8;border-width:1px;border-style:solid;border-color:#666666;overflow:visible;height:auto;width: auto;position:absolute;left:'+left+'px;top:'+top+'px;width:'+width+';height:'+height+'; visibility:visible'+'; z-index:'+zindex+';text-align:left">'+msg+'</DIV>';
			document.body.insertAdjacentHTML("BeforeEnd",layer);}
		else if(document.getElementById){
			var layer=document.createElement('div');layer.setAttribute('id',id);document.body.appendChild(layer);var ly=document.getElementById(id);ly.className="picker_layer";ly.style.position="absolute";ly.style.left=left+"px";ly.style.top=top+"px";ly.style.width=width+"px";ly.style.height=height+"px";ly.style.textAlign="left";ly.innerHTML=msg;}
	}

	function showClr(color){displayClr(color);Obj=document.getElementById("gcpicker_colorCode");Obj.value=color.toUpperCase();}
	this.showClr=showClr;
	function displayClr(color){Obj=document.getElementById("gcpicker_colorSample");Obj.style.backgroundColor=color;}
	this.displayClr=displayClr;
	function setClrcolorselect(color){bbcobj.alterfont(color.toUpperCase(),'color','message','');removeAllPickerLayers();}
	this.setClrcolorselect=setClrcolorselect;
	function setClrHTBGselect(color){bbcobj.alterfont(color.toUpperCase(),defHighlight,'message','');removeAllPickerLayers();}
	this.setClrHTBGselect=setClrHTBGselect;

	function removePickerLayer(id){
		delete pickedLayers[id];
		if(document.getElementById(id)==null){return;}
		if(document.layers&&document.layers[id]){document.layers[id].visibility='hide';delete document.layers[id];}
		if(document.all&&document.all[id]){document.all[id].innerHTML='';document.all[id].outerHTML='';}
		else if(document.getElementById){var b=document.body;var layer=document.getElementById(id);b.removeChild(layer);}
	}

	function removeOtherPickerLayers(layerToSave){for(pLayer in pickedLayers){if(pLayer!=layerToSave){removePickerLayer(pLayer);}}}
	function removeAllPickerLayers(){for(pLayer in pickedLayers){removePickerLayer(pLayer);}}
	this.removeAllPickerLayers=removeAllPickerLayers;

	function getPickerContent(id){var content='<table width="222" border="0" cellpadding="0" cellspacing="1" style="background-color:#CCCCCC;border:2px outset #CCCCCC;"><tr><td><table width="100%" border="0" cellpadding="0" cellspacing="1" style="font-family:Arial,Helvetica,sans-serif;font-size:12px;text-decoration:none;"><tr><td bgcolor="#CCCCCC" id="gcpicker_colorSample" width="40" style="border-style:solid;border-color:#000000;border-width:1px;">&nbsp;</td><td align="center"><input type="text" id="gcpicker_colorCode" value="#CCCCCC" onkeyup="bbcobj.displayClr(this.value);" onchange="bbcobj.displayClr(this.value);" style="width:110px;" maxlength="7"/><input type="button" value=">" onclick="bbcobj.setClr'+id+'(document.getElementById(\'gcpicker_colorCode\').value);"/></td><td align="right"><input type="submit" value="" onclick="bbcobj.removeAllPickerLayers('+id+')" style="width:17px;height:17px;background-image:url(\''+DefMsgIconUrl+'close.gif\');background-repeat:no-repeat;background-position:center;"/></td></tr></table></td></tr><tr><td>'+colorTable(id)+'</td></tr></table>';return content;}

	function colorTable(id){
		var clrfix=Array("#000000","#333333","#666666","#999999","#cccccc","#ffffff","#ff0000","#00ff00","#0000ff","#ffff00","#00ffff","#ff00ff");
		var table='<table border="0"  cellpadding="0" cellspacing="0" bgcolor="#000000"><tr>';table+='';
		for(var j=0;j<3;j++){
			table+='<td width="11"><table bgcolor="#000000"  border="0"  cellpadding="0" cellspacing="1" style="font-family:Arial,Helvetica,sans-serif;font-size:12px;text-decoration:none;">';
			for(var i=0;i<12;i++){var clr='#000000';if(j==1){clr=clrfix[i];}
				table+='<tr><td bgcolor="'+clr+'" style="cursor:pointer;width:9px;height:9px;" onmouseover="bbcobj.showClr('+"'"+clr+"'"+')" onclick="bbcobj.setClr'+id+'('+"'"+clr+"'"+')"></td></tr>';}
			table+='</table></td>';}
		table+='<td><table border="0" cellpadding="0" cellspacing="0">';
		for(var c=0;c<6;c++){
			if(c==0||c==3){table+="<tr>";}table+="<td>";
			table=table+'<table border="0" cellpadding="0" cellspacing="1" style="font-family:Arial,Helvetica,sans-serif;font-size:12px;text-decoration:none;"> ';
			for(var j=0;j<6;j++){table+="<tr>";
				for (var i=0;i<6;i++){
					var clrhex=rgb2hex(j*255/5,i*255/5,c*255/5);
					table+='<td bgcolor="'+clrhex+'" style="cursor:pointer;width:9px;height:9px;" onmouseover="bbcobj.showClr('+"'"+clrhex+"'"+')" onclick="bbcobj.setClr'+id+'('+"'"+clrhex+"'"+')"></td>';}
				table +="</tr>";}
			table+="</table>";table+="</td>"	
			if(c==2||c==5){table+="</tr>";}}
		table+='</table></td></tr></table>';return table;
	}

	function findPosX(obj){
		var curleft=0;
		if(obj.offsetParent)
		while(1){curleft+=obj.offsetLeft;if(!obj.offsetParent) break;
			obj=obj.offsetParent;}
		else if(obj.x) curleft+=obj.x;
		return curleft;
	}

	function findPosY(obj){
		var curtop=0;
		if(obj.offsetParent){
			while(1){curtop+=obj.offsetTop;
			if(!obj.offsetParent){break;}
			obj=obj.offsetParent;}
		}else if(obj.y){curtop+=obj.y;}
		return curtop;
	}

	function rgb2hex(red,green,blue){
		var decColor=red+256*green+65536*blue,clr=decColor.toString(16);
		for(var i=clr.length;i<6;i++){clr="0"+clr;}
		return "#"+clr;
	}
	
	this.oncetag=function(tag,wh){doInsert("["+tag+"]","",false,wh);}

	this.tag_cut=function(wh,ev){
		if(ev&&ev.altKey){this.simpletag(defCut,'','','message','');return;}
		var x1="";var enterCODE=isSelected(wh),enterTITLE=prompt("  "," ");
		if(!enterTITLE){return;}if(!dCHG&&confirm("   ?")){x1=" noguest";}
		if(enterTITLE==" "){doInsert("["+defCut+x1+"]"+enterCODE+"[/"+defCut+"]","",false,wh);
		}else{doInsert("["+defCut+x1+"="+enterTITLE+"]"+enterCODE+"[/"+defCut+"]","",false,wh);}
	}

	this.tag_image=function(wh,ev){
		this.advtagQ('img',[text_enter_image],['http://example.com/my_picture.jpg'],false,[true,false],false,false,wh,ev);}
	this.tag_email=function(wh,ev){
		this.advtagQ('email',[text_enter_email],['anyone@example.com'],[EMLrXp],[true,true],false,false,wh,ev);}
	this.tag_hide=function(wh,ev){
		this.advtagQ('hide',['   '],['0'],[HIDrXp],[false,false],false,true,wh,ev);}
	this.tag_url=function(wh,ev){
		this.advtagQ('url',[text_enter_url,text_enter_url_name],['http://example.com/index.html','My WebPage'],false,[true,true],[false,true],false,wh,ev);}
	this.tag_video=function(wh,ev){
		this.advtagQ('video',[" URL-"],["http://youtube.com/watch?v="],false,[true,false],false,false,wh,ev);}
	this.tag_flv=function(wh,ev){
		this.advtagQ(defPlayer,[" URL-"],["http://example.com/my_video.flv"],false,[true,false],false,false,wh,ev);}
	this.tag_stext=function(wh,ev){
		this.advtagQ(defSText,["  "],[' '],false,[false,true],[false,true],false,wh,ev);}
	this.tag_audio=function(wh,ev){
		this.advtagQ('audio',[" URL-"],["http://example.com/my_music.mp3"],false,[true,false],false,false,wh,ev);}

	this.tag_table=function(wh,ev)
	{
		if(ev&&ev.altKey){doInsert('[table][tr][td colspan=2][/td][/tr][tr][td][/td][td][/td][/tr][/table]',"",false,wh);return;}
		var trows=false,tcols=false,TblRegExp=/^\d+$/;
		trows=prompt("   ","");
		while(trows&&(!TblRegExp.test(trows)||trows>100)){trows=prompt("   ","");}
		if(!trows||trows==0){return;}
		tcols=prompt("   ","");
		while(tcols&&(!TblRegExp.test(tcols)||tcols>10)){tcols=prompt("   ","");}
		if(!tcols||tcols==0){return;}
		tblcodes="[table]";
		for(p=0;p<trows;p++){tblcodes+="[tr]";for(u=0;u<tcols;u++){tblcodes+="[td][/td]";}tblcodes+="[/tr]";}
		tblcodes+="[/table]";
		doInsert(tblcodes,"",false,wh);
	}

	this.tag_list=function(wh,ev){
		var enterCODE=isSelected(wh),thelist="";
		if(enterCODE){
			enterCARR=enterCODE.split("\n");
			for(dz=0;dz<enterCARR.length;dz++){if(enterCARR[dz]){thelist+="[*]"+enterCARR[dz]+"\n";}}
		}else{thelist="";}
		if(ev&&ev.altKey){doInsert("[list]\n"+(thelist?thelist:"[*]\n")+"[/list]\n","",false,wh);return;}
		var listvalue="init";
		while(listvalue!=""&&listvalue!=null)
		{
			listvalue=prompt(list_prompt,"");
			if(listvalue!=""&&listvalue!=null){
				thelist+="[*]"+listvalue+"\n";}
		}
		if(thelist!=""){doInsert( "[list]\n"+thelist+"[/list]\n", "",false,wh);}
	}

	this.advtagQ=function(tag,Q,defQ,uRxpS,bRepSel,bAllowNo,bAllowDef0,wh,ev){
		if(!Q||Q.constructor!=Array){return;}if(!defQ||defQ.constructor!=Array){defQ=[];}if(!uRxpS||uRxpS.constructor!=Array){uRxpS=[];}
		if(Q.length>2||defQ.length>2||uRxpS.length>2){return;}if(!bAllowNo||bAllowNo.constructor!=Array){bAllowNo=[];}
		if(!bRepSel||bRepSel.constructor!=Array){bRepSel=[];}if(!bAllowDef0){bAllowDef0=false;}
		if(ev&&ev.altKey){this.simpletag(tag,'','',wh,'');return;}
		var selection=isSelected(wh),uAnswers=[];
		if(!(selection.length>0&&bRepSel[0]&&!bRepSel[1])){
			uAnswers[0]=prompt(Q[0],defQ[0]?defQ[0]:'');
			while(uAnswers[0]&&((uRxpS[0]&&!uRxpS[0].test(uAnswers[0]))||(defQ[0]&&!bAllowDef0&&uAnswers[0]==defQ[0]))){
				uAnswers[0]=prompt(Q[0],defQ[0]?defQ[0]:'');}
			if(!bAllowNo[0]&&(!uAnswers[0]||uAnswers[0]=='')){return;}}
		if(selection.length>0){uAnswers[1]=selection}else if(Q[1]){
			uAnswers[1]=prompt(Q[1],defQ[1]?defQ[1]:'');
			while(uAnswers[1]&&uRxpS[1]&&!uRxpS[1].test(uAnswers[1])){
				uAnswers[1]=prompt(Q[1],defQ[1]?defQ[1]:'');}
			if(!bAllowNo[1]&&(!uAnswers[1]||uAnswers[1]=='')){return;}}
		if(uAnswers[1]&&bRepSel[1]&&!(bAllowDef0&&uAnswers[0]==defQ[0])){doInsert("["+tag+(uAnswers[0]?"="+uAnswers[0]:'')+"]"+uAnswers[1]+"[/"+tag+"]","",false,wh);
		}else if(uAnswers[1]&&bRepSel[1]&&(bAllowDef0&&uAnswers[0]==defQ[0])){
			doInsert("["+tag+"]"+uAnswers[1]+"[/"+tag+"]","",false,wh);
		}else if(uAnswers[1]&&!bRepSel[1]&&!(bAllowDef0&&uAnswers[0]!=defQ[0])){
			doInsert("["+tag+"]"+uAnswers[1]+"[/"+tag+"]","",false,wh);
		}else if(bRepSel[0]){doInsert("["+tag+"]"+(uAnswers[0]?uAnswers[0]:'')+"[/"+tag+"]","",false,wh);
		}else if(uAnswers[1]&&bAllowDef0&&uAnswers[0]!=defQ[0]){
			doInsert("["+tag+(uAnswers[0]?"="+uAnswers[0]:'')+"]"+uAnswers[1]+"[/"+tag+"]","",false,wh);
		}else if(!(bAllowDef0&&uAnswers[0]==defQ[0])){doInsert("["+tag+(uAnswers[0]?"="+uAnswers[0]:'')+"][/"+tag+"]","",false,wh);
		}else{doInsert("["+tag+"][/"+tag+"]","",false,wh);}
	}

	this.symbolinssert=function(symbol,wh){doInsert(symbol,"",false,wh);}

	this.DrawPanel=function(){document.write(BBCPanel());}

	function BBCPanel(){return('<span style="display:none;"><img src="'+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageDefault+'" border="0" width="0" height="0"><img src="'+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageOver+'" border="0" width="0" height="0"><img src="'+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageMark+'" border="0" width="0" height="0"><img src="'+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageMarked+'" border="0" width="0" height="0"></span><div class="bbc1" style="padding-right:1px;'+(DefMsgPanelBGImage?'background:url(\''+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgPanelBGImage+'\');':'')+'">'+panel_array().join("")+'<input type="hidden" name="tagcount" value="0"></div>');}

	this.bbc_highlight=function(something, mode, marked)
	{
		if(marked){
			_bb_hihglight_array.push(something);
			something.style.backgroundImage="url("+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageMarked+")";}
		else{
			something.style.backgroundImage=("url("+DefMsgIconUrl+_bb_PanelButtonTheme+(mode?DefMsgIconBackgroundImageOver:DefMsgIconBackgroundImageDefault)+")");}
	}

	this.bbc_clicklight=function(something){
		something.style.backgroundImage="url("+DefMsgIconUrl+_bb_PanelButtonTheme+DefMsgIconBackgroundImageMark+")";}

	this._bb_clearmarkedhighlightfromall=function()
	{
		while(_bb_hihglight_array.length>0){
			this.bbc_highlight(_bb_hihglight_array.pop(), false, false);}
	}

	this._bb_highlightmarkedremove=function(what,stag)
	{
		if(what==stag){return;}
		var temparray=new Array();var tempvar=null;
		while(_bb_hihglight_array.length>0){
			tempvar=_bb_hihglight_array.pop();
			if(tempvar!=what){
				temparray.push(tempvar);}
			tempvar=null;}
		_bb_hihglight_array=temparray;
		this.bbc_highlight(what, false, false);
		return true;
	}

	function _bb_set(value1,value2){return(new Array(value1,value2));}

	function _bb_Button(param)
	{
		var _button_build_result=null;
		for(i=0;i<param.length;i++){
			if(param[i][0]=="Type"){_bb_type=param[i][1];}
			if(param[i][0]=="Value"){_bb_value=param[i][1];}
			if(param[i][0]=="Where"){_bb_where=param[i][1];}
			if(param[i][0]=="Title"){_bb_title=param[i][1];}
			if(param[i][0]=="GIFImage"){_bb_GIFImage=param[i][1];}
			if(param[i][0]=="Special"){_bb_special=param[i][1];}}
		_button_build_result=_bb_Button_build();
		_bb_reset();
		return(_button_build_result);
	}

	function _bb_reset()
	{
		_bb_type=0;
		_bb_value=null;
		_bb_where="message";
		_bb_name="";
		_bb_title="";
		_bb_GIFImage="empty";
		_bb_special=null;
	}

	this._bb_userblock_togglepict=function(tpelement)
	{
		if(tpelement.src==DefMsgIconUrl+x_imageBlockIcon_cl){
			tpelement.src=DefMsgIconUrl+x_imageBlockIcon_op;}
		else{
			tpelement.src=DefMsgIconUrl+x_imageBlockIcon_cl;}
	}

	function new_bb_Block(blockArray)
	{
		retBlock=bb_inblock_st();
		retBlock+=blockArray.join("");
		retBlock+=bb_inblock_post_st();
		_bb_blockcount++;
		return(retBlock);
	}

	function _bb_Button_build()
	{
		_bb_button_build_code='<img '+(_bb_value?('id="xbb_button_'+_bb_value+'"'):'')+' align="middle"';
		if(HighLightButtons){
			_bb_button_build_code+='onmousedown="bbcobj.bbc_clicklight(this);" ';
			if((_bb_typearray[_bb_type]=="special"||_bb_typearray[_bb_type]=="simple")&&_bb_value&&HighLightUnclosedTagButtons){
				_bb_button_build_code+='onmouseover="bbcobj.bbc_highlight(this,true,(document.addform.'+(_bb_value=="code"?"codes":_bb_value)+'.value.indexOf(\'*\')>-1?true:false));" onmouseout="bbcobj.bbc_highlight(this,false,(document.addform.'+(_bb_value=="code"?"codes":_bb_value)+'.value.indexOf(\'*\')>-1?true:false));" onmouseup="bbcobj.bbc_highlight(this,true,(document.addform.'+(_bb_value=="code"?"codes":_bb_value)+'.value.indexOf(\'*\')>-1?false:true));" ';}
			else{
				_bb_button_build_code+='onmouseover="bbcobj.bbc_highlight(this,true,false);" onmouseout="bbcobj.bbc_highlight(this,false,false);" onmouseup="bbcobj.bbc_highlight(this, true, false);" ';}}
		_bb_button_build_code+='style="background:'+DefMsgIconBackground+';" border=0 src="'+DefMsgIconUrl+(_bb_PanelImgTheme?"ImgTheme/"+_bb_PanelImgTheme+"/":'')+_bb_GIFImage+'.gif" alt="'+(_bb_value?_bb_value:"button")+'" title="'+_bb_title+'"';
		if(_bb_type<=_bb_typearray.length){
			_bb_button_build_code+='onclick="';
			if(_bb_typearray[_bb_type]=="simple"&&_bb_value){
				_bb_button_build_code+="bbcobj.simpletag('"+_bb_value+"','','','"+_bb_where+"','');";
				_bb_simplecodes_array.push(_bb_value);}
			if(_bb_typearray[_bb_type]=="once"&&_bb_value){
				_bb_button_build_code+="bbcobj.oncetag('"+_bb_value+"','"+_bb_where+"');";}
			if(_bb_special&&_bb_typearray[_bb_type]!="none"){
				_bb_button_build_code+=_bb_special;}
			_bb_button_build_code+='"';}
		_bb_button_build_code+='>';
		if(_bb_value){_bb_button_build_code+=('<input type="hidden" name="'+(_bb_value=="code"?"codes":_bb_value)+'" value="'+_bb_value+'">');}
		_bb_reset();
		return(_bb_button_build_code);
	}

	//    bbcodes.js(http://src.ucoz.net/src/bbcodes.js)
	//----------------------------bbcodes.js-----------------------------//
	var opens=[],bbtags=new Array(),myAgent=navigator.userAgent.toLowerCase(),myVersion=parseInt(navigator.appVersion),is_ie=((myAgent.indexOf("msie")!=-1)&&(myAgent.indexOf("opera")==-1)),is_nav=((myAgent.indexOf('mozilla')!=-1)&&(myAgent.indexOf('spoofer')==-1)&&(myAgent.indexOf('compatible')==-1)&&(myAgent.indexOf('opera')==-1)&&(myAgent.indexOf('webtv')==-1)&&(myAgent.indexOf('hotjava')==-1)),is_win=((myAgent.indexOf("win")!=-1)||(myAgent.indexOf("16bit")!=-1)),is_mac=(myAgent.indexOf("mac")!=-1);

	function hstat(msg){try{document.addform.helpbox.value=eval("help_"+msg);}catch(e){}}

	function cstat(fi){
		if(!fi){fi='';}
		var c=stacksize(bbtags);
		if((c<1)||(c==null)){c=0;}
		if(!bbtags[0]){c=0;}
		eval('document.addform.tagcount'+fi+'.value='+c);
	}

	function stacksize(thearray){
		for(i=0;i<thearray.length;i++){
			if((thearray[i]=="")||(thearray[i]==null)||(thearray=='undefined')){return i;}}
		return thearray.length;
	}

	function pushstack(thearray,newval,fi){
		arraysize=stacksize(thearray);
		thearray[arraysize]=newval;
	}

	function popstack(thearray){
		arraysize=stacksize(thearray);
		theval=thearray[arraysize-1];
		delete thearray[arraysize-1];
		return theval;
	}

	this.closeall=function(wh,fi){
		if(!fi){fi='';}
		if(!wh){wh='message';}
		this._bb_clearmarkedhighlightfromall();
		if(bbtags[0]){
			try{
				while(bbtags[0]){
					tagRemove=popstack(bbtags);
					document.getElementById(wh).value+="[/"+tagRemove + "]";
					if((tagRemove!='font')&&(tagRemove!='size')&&(tagRemove!='color')){
						if(tagRemove=='code'){
							eval("document.addform.codes"+fi+".value=' "+tagRemove+" '");
						}else{
							eval("document.addform."+tagRemove+fi+".value=' " + tagRemove + " '");}
						opens[tagRemove+fi]=0;}}}
			catch(e){}
		}
		eval('document.addform.tagcount'+fi+'.value=0');
		bbtags=new Array();
		document.getElementById(wh).focus();
	}

	this.emoticon=function(tS,wh){doInsert(" "+tS+" ","",false,wh);}

	this.alterfont=function(theval,thetag,wh,fi){if(!fi){fi='';}if(theval==0)return;if(doInsert("["+thetag+"="+theval+"]","[/"+thetag+"]",true,wh))	pushstack(bbtags,thetag);cstat(fi);}

	this.simpletag=function(thetag,fid,chtxt,wh,fi,di){
		if(!fi){fi='';}if(!di){di='';}
		var tagOpen=opens[thetag+fid];
		if(!tagOpen){
			if(doInsert("["+thetag+(di?"="+di:"")+"]","[/"+thetag+"]",true,wh)){
				opens[thetag+fid]=1;
				if(fid){
					document.getElementById(fid).value=chtxt+'*';
				}else{
					if(thetag=='code'){
						eval("document.addform.codes"+fi+".value+='*'");
					}else{
						eval("document.addform."+thetag+fi+".value+='*'");}}
				pushstack(bbtags,thetag,fi);
				cstat(fi);
				hstat('click_close');
			}else{
				this.bbc_highlight(document.getElementById("xbb_button_"+thetag),false,false);}
		}else{
			lastindex=0;
			for(i=0;i<bbtags.length;i++){if(bbtags[i]==thetag){lastindex=i;}}
			while(bbtags[lastindex]){
				tagRemove=popstack(bbtags);
				doInsert("[/"+tagRemove+"]","",false,wh);
				if((tagRemove!='font')&&(tagRemove!='size')&&(tagRemove != 'color')){
					this._bb_highlightmarkedremove(document.getElementById("xbb_button_"+tagRemove),document.getElementById("xbb_button_"+thetag));
					if(fid){
						document.getElementById(fid).value=chtxt;
					}else{
						if(thetag=='code'){
							eval("document.addform.codes"+fi+".value='"+tagRemove+"'");
						}else{
							eval("document.addform."+tagRemove+fi+".value='"+tagRemove+"'");}}
					opens[tagRemove+fid]=0;}}
			cstat(fi);}
	}

	function doInsert(ibTag,ibClsTag,isSingle,wh){
		if(!wh){wh='message';}
		var isClose=false,obj_ta=document.getElementById(wh);
		if((myVersion>=4)&&is_ie&&is_win){
			if(obj_ta.isTextEdit){
				obj_ta.focus();
				var sel=document.selection,rng=sel.createRange();
				rng.colapse;
				if((sel.type=="Text"||sel.type=="None")&&rng!=null){
					if(ibClsTag!=""&&rng.text.length>0) ibTag+=rng.text+ibClsTag;
					else if(isSingle) isClose=true;
					rng.text=ibTag;}
			}else{
				if(isSingle) isClose=true;
				obj_ta.value+=ibTag;}
		}else try{
			var txtStart=obj_ta.selectionStart;
			if(!(txtStart>=0)) throw 1;
			var txtEnd=obj_ta.selectionEnd,firstPos=txtStart+ibTag.length,secondPos=txtEnd+ibTag.length,scrollpos=false;
			if(is_nav){scrollpos=obj_ta.scrollTop;}
			if(ibClsTag!=""&&obj_ta.value.substring(txtStart,txtEnd).length>0){
				obj_ta.value=obj_ta.value.slice(0,txtStart)+ibTag+obj_ta.value.slice(txtStart);
				obj_ta.value=obj_ta.value.slice(0,secondPos)+ibClsTag+obj_ta.value.slice(secondPos);
				obj_ta.selectionStart=txtStart;
				obj_ta.selectionEnd=secondPos+ibClsTag.length;
			}else{
				if(isSingle) isClose=true;
				if(isSelected(wh).length>0){
					obj_ta.value=obj_ta.value.slice(0,txtStart)+ibTag+obj_ta.value.slice(txtEnd);
					obj_ta.selectionStart=txtStart;
					obj_ta.selectionEnd=firstPos;
				}else{
					obj_ta.value=obj_ta.value.slice(0,txtStart)+ibTag+obj_ta.value.slice(txtStart);
					obj_ta.selectionStart=txtStart+ibTag.length;
					obj_ta.selectionEnd=txtStart+ibTag.length;}}
			if(scrollpos){obj_ta.scrollTop=scrollpos;}
		}catch(e){
			if(isSingle) isClose=true;
			obj_ta.value+=ibTag;}
		obj_ta.focus();
		return isClose;
	}

	function isSelected(wh){
		if(!wh){wh='message';}
		var obj_ta=document.getElementById(wh);
		if((myVersion>=4)&&is_ie&&is_win){
			if(obj_ta.isTextEdit){
				obj_ta.focus();
				var sel=document.selection,rng=sel.createRange();
				rng.colapse;
				if((sel.type=="Text"||sel.type=="None")&&rng!=null){
					if(rng.text.length>0){
						return rng.text;}}}
			return '';}
		try{
			var txtStart=obj_ta.selectionStart;
			if(!(txtStart>=0)) throw 1;
			var txtEnd=obj_ta.selectionEnd;
			if(obj_ta.value.substring(txtStart,txtEnd).length>0){
				return obj_ta.value.substring(txtStart,txtEnd);}
		}catch(e){}
		return '';
	}
	//------------------------- bbcodes.js--------------------------//
}

var bbcobj;if(!bbcobj){bbcobj=new BBComplex();}
var bbComplete=function(){bbcobj.bbComplete();}
var ShowHiddenSpoiler;
var StartBBComplex=function(){if(ShowHiddenSpoiler){bbcobj.setULI();}bbcobj.StartBBComplex();}
var bbComplete=bbcobj.bbComplete;
var alterfont=bbcobj.alterfont;
var closeall=bbcobj.closeall;
var DrawBBCodesPanel=bbcobj.DrawPanel;
var emoticon=bbcobj.emoticon;
var hideblock=bbcobj.hide;
var showblock=bbcobj.show;
var simpletag=bbcobj.simpletag;
var tag_list=bbcobj.tag_list;